import { getAll } from '@/api/system/role';

// 与vue2的里面的data一样，函数返回新对象防止多处共用同一对象,造成数据混乱
export const getFormSchema = (): FormSchema => ({
  style: {
    width: 'auto'
  },
  formItemLayout: {
    layout: 'inline',
    labelCol: {
      span: 7
    },
    wrapperCol: {
      span: 17
    }
  },
  formItem: [
    {
      type: 'input',
      label: '用户名称',
      field: 'username',
      value: '',
      disabled: true
    },
    {
      type: 'select',
      props: {
        mode: 'multiple'
      },
      label: '角色',
      field: 'roleIds',
      rules: [
        {
          required: true,
          message: '请选择角色',
          type: 'array'
        }
      ],
      value: [],
      options: [],
      asyncOptions: async () => {
        const { retData } = await getAll();
        return retData.map((item) => ({
          label: item.roleName,
          value: item.id
        }));
      }
    },
    {
      type: 'input',
      label: '电话',
      field: 'phone',
      value: '',
      props: {
        placeholder: '请输入电话'
      },
      rules: [
        {
          required: true,
          message: '电话不能为空'
        }
      ]
    },
    {
      type: 'input',
      label: '用户ID',
      field: 'userid',
      value: '',
      disabled: true
    },
    {
      type: 'input',
      label: '登录名称',
      field: 'loginname',
      value: '',
      disabled: true
    },
    {
      type: 'input',
      label: '备用登录名称',
      field: 'loginnamedjjg',
      value: '',
      disabled: true
    },
    {
      type: 'input',
      label: '组织机构',
      field: 'groupName',
      value: '',
      disabled: true
    },
    {
      type: 'radio',
      label: '有效状态',
      field: 'useful',
      value: '',
      disabled: true,
      options: [
        {
          label: '有效',
          value: 1
        },
        {
          label: '无效',
          value: 0
        }
      ]
    },
    {
      type: 'input',
      label: '邮箱',
      field: 'email',
      value: '',
      disabled: true
    },
    {
      type: 'radio',
      label: '是否在编',
      field: 'official',
      value: '',
      disabled: true,
      options: [
        {
          label: '是',
          value: 1
        },
        {
          label: '不是',
          value: 0
        }
      ]
    },
    {
      type: 'select',
      label: '编制类别',
      field: 'officialtype',
      value: '',
      disabled: true,
      options: [
        {
          label: '公务员',
          value: 1
        },
        {
          label: '事业编',
          value: 2
        },
        {
          label: '合同工',
          value: 3
        }
      ]
    },
    {
      type: 'input',
      label: '性别',
      field: 'sex',
      value: '',
      disabled: true
    },
    {
      type: 'select',
      label: '证件类型',
      field: 'idtype',
      disabled: true,
      value: '',
      options: [
        {
          label: '身份证',
          value: 1
        },
        {
          label: '军官证',
          value: 3
        },
        {
          label: '士兵证',
          value: 4
        },
        {
          label: '户口簿',
          value: 5
        },
        {
          label: '护照',
          value: 2
        }
      ]
    },
    {
      type: 'input',
      label: '证件编号',
      field: 'idnum',
      value: '',
      disabled: true
    },
    {
      type: 'input',
      label: '登记机关',
      field: 'djjg',
      value: '',
      disabled: true
    },
    {
      type: 'input',
      label: '审批权限',
      field: 'spqx',
      value: '',
      disabled: true
    },
    {
      type: 'input',
      label: '创建时间',
      field: 'createtime',
      value: '',
      disabled: true
    },
    {
      type: 'input',
      label: '描述',
      field: 'description',
      value: '',
      disabled: true
    },
    {
      type: 'input',
      label: '管辖单位',
      field: 'gxdwdm',
      value: '',
      disabled: true
    },
    {
      type: 'input',
      label: '更新时间',
      field: 'updatetime',
      value: '',
      disabled: true
    }
  ]
});
